//
//  BasicViewController.swift
//  WeiBo
//
//  Created by 陈贵 on 15/9/7.
//  Copyright © 2015年 hzj. All rights reserved.
//

import UIKit

class BasicViewController: UITableViewController {

    //判断是否登录
    var islogin =  UserAccountViewModel.sharedUserAccountViewModel.isLogin
    
    var visitorView:VisitorView?
    
    
    override func loadView() {
        
        islogin ? super.loadView(): addVisitorView()
        
    }
    
    //访客界面
    private func addVisitorView(){
        
        visitorView = VisitorView()
        view = visitorView
        
//       设置导航按钮
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "clickTheZhuCeBth")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "clickTheLoginBth")
        
        visitorView?.registerBth.addTarget(self, action: "clickTheZhuCeBth", forControlEvents: UIControlEvents.TouchUpInside)
        visitorView?.loginBth.addTarget(self, action: "clickTheLoginBth", forControlEvents: UIControlEvents.TouchUpInside)
        
    }
    
    
//    MARK:代理方法
    @objc private func clickTheZhuCeBth(){
        print("注册")
    }
    
    
    @objc private func clickTheLoginBth(){
        
        //跳转到授权页
        let nac = UINavigationController(rootViewController: OAuthViewController())
        presentViewController(nac, animated: true) { () -> Void in
            
        }
    }

  }
